home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fromdl / fromdll.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-19  |  4.7 KB  |  163 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "From a DLL"
  5.    ClientHeight    =   5700
  6.    ClientLeft      =   1125
  7.    ClientTop       =   2715
  8.    ClientWidth     =   7245
  9.    Height          =   6105
  10.    Icon            =   FROMDLL.FRX:0000
  11.    Left            =   1065
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5700
  14.    ScaleWidth      =   7245
  15.    Top             =   2370
  16.    Width           =   7365
  17.    Begin PictureBox Picture2 
  18.       Height          =   2895
  19.       Left            =   3720
  20.       ScaleHeight     =   2865
  21.       ScaleWidth      =   3405
  22.       TabIndex        =   8
  23.       Top             =   2460
  24.       Width           =   3435
  25.    End
  26.    Begin CommandButton btnClearPic 
  27.       Caption         =   "Clear Picture"
  28.       Height          =   495
  29.       Left            =   1980
  30.       TabIndex        =   7
  31.       Top             =   1860
  32.       Width           =   1695
  33.    End
  34.    Begin CommandButton btnPic 
  35.       Caption         =   "Load &Picture"
  36.       Height          =   495
  37.       Left            =   180
  38.       TabIndex        =   6
  39.       Top             =   1860
  40.       Width           =   1695
  41.    End
  42.    Begin PictureBox Picture1 
  43.       AutoRedraw      =   -1  'True
  44.       Height          =   2895
  45.       Left            =   180
  46.       ScaleHeight     =   191
  47.       ScaleMode       =   3  'Pixel
  48.       ScaleWidth      =   227
  49.       TabIndex        =   5
  50.       Top             =   2460
  51.       Width           =   3435
  52.    End
  53.    Begin CommandButton btnCallDll 
  54.       Caption         =   "Call DLL"
  55.       Height          =   495
  56.       Left            =   180
  57.       TabIndex        =   4
  58.       Top             =   1200
  59.       Width           =   1695
  60.    End
  61.    Begin CommandButton btnStr2 
  62.       Caption         =   "String 2"
  63.       Height          =   495
  64.       Left            =   1980
  65.       TabIndex        =   3
  66.       Top             =   600
  67.       Width           =   1695
  68.    End
  69.    Begin CommandButton btnStr1 
  70.       Caption         =   "String 1"
  71.       Height          =   495
  72.       Left            =   180
  73.       TabIndex        =   2
  74.       Top             =   600
  75.       Width           =   1695
  76.    End
  77.    Begin TextBox Text1 
  78.       Height          =   285
  79.       Left            =   180
  80.       TabIndex        =   1
  81.       Top             =   180
  82.       Width           =   6975
  83.    End
  84.    Begin CommandButton btnExit 
  85.       Caption         =   "E&xit"
  86.       Height          =   495
  87.       Left            =   5880
  88.       TabIndex        =   0
  89.       Top             =   1200
  90.       Width           =   1215
  91.    End
  92.    Begin Label Label2 
  93.       AutoSize        =   -1  'True
  94.       BackStyle       =   0  'Transparent
  95.       Caption         =   "Copied from other Picture"
  96.       Height          =   195
  97.       Left            =   3720
  98.       TabIndex        =   10
  99.       Top             =   5400
  100.       Width           =   2175
  101.    End
  102.    Begin Label Label1 
  103.       AutoSize        =   -1  'True
  104.       BackStyle       =   0  'Transparent
  105.       Caption         =   "Loaded from DLL"
  106.       Height          =   195
  107.       Left            =   180
  108.       TabIndex        =   9
  109.       Top             =   5400
  110.       Width           =   1470
  111.    End
  112. Option Explicit
  113. Sub btnCallDll_Click ()
  114. Dim r%
  115. r% = SayHi()
  116. End Sub
  117. Sub btnClearPic_Click ()
  118. picture2.Picture = LoadPicture()
  119. picture1.Picture = LoadPicture()
  120. End Sub
  121. Sub btnExit_Click ()
  122. FreeLibrary (DLLID%)
  123. End Sub
  124. Sub btnPic_Click ()
  125. Dim hMyBitmap%, hdcmemory%
  126. Dim r%, dccontrol%, cx%, cy%, pict1%
  127. picture1.ScaleMode = 3
  128. dccontrol% = picture1.hDC
  129. cx% = picture1.ScaleWidth
  130. cy% = picture1.ScaleHeight
  131. ' load bitmap from DLL
  132. hMyBitmap% = LoadBitmap(DLLID%, "CPARROW")
  133. ' Create context compatible with the picture box
  134. hdcmemory% = CreateCompatibleDC(dccontrol%)
  135. ' select bitmap into device context
  136. r% = SelectObject(hdcmemory%, hMyBitmap%)
  137. ' Copy it
  138. r% = BitBlt(dccontrol%, 0, 0, cx%, cy%, hdcmemory%, 0, 0, SRCCOPY)
  139. picture1.Picture = picture1.Image ' move presistent image to visible
  140. picture2.Picture = picture1.Picture ' prove it can be moved
  141. r% = DeleteDC(hdcmemory%)      ' delete device context
  142. r% = DeleteObject(hMyBitmap%)  ' delete object (free memory!)
  143. End Sub
  144. Sub btnStr1_Click ()
  145. Dim temp$, r%
  146. temp$ = Space(80)
  147. r% = LoadString(DLLID%, 1, temp$, Len(temp$))
  148. text1 = Trim(temp$)
  149. End Sub
  150. Sub btnStr2_Click ()
  151. Dim temp$, r%
  152. temp$ = Space(80)
  153. r% = LoadString(DLLID%, 2, temp$, Len(temp$))
  154. text1 = Trim(temp$)
  155. End Sub
  156. Sub Form_Load ()
  157. DLLID% = LoadLibrary("TEST.DLL")
  158. If DLLID% < 32 Then
  159.     MsgBox "Error loading DLL"
  160.     End
  161. End If
  162. End Sub
  163.